<div class="wp-20 app-detail">
    <ol class="breadcrumb">
        <li>广告中心</li>
        <li><a ui-sref="app"class="tittle-color" ui-sref-opts="{inherit:false}">应用</a></li>
        <li>应用{{!planEdit ? "详情" : formData.appId ? "修改" : "新建"}}</li>
    </ol>
    <div class="clearfix mt-10"  ng-show="formData.appId">
        <label class="title" title="应用ID">
            <label>I</label>
            <span>{{formData.appId}}</span>
        </label>
        <label class="title" title="应用名称">
            <label>N</label>
            <span>{{formData.appName}}</span>
        </label>
    </div>

    <form class="form-horizontal" name="mainForm" ng-class="{planShow: !planEdit}" novalidate>
        <section class="fg-section">
            <h5>基本设置</h5>

            <div class="form-group" ng-hide="formData.appId" >
                <label class="col-sm-2 control-label">渠道主</label>

                <div class="col-sm-8">
                    <div>
                        <input type="text" class="form-control pull-left mw-300" ng-model="ctrlData.shortName" readonly>
                        <a class="btn btn-link pull-left" ng-click="modelOpen(modelChannelParam)">选择</a>
                    </div>
                </div>
            </div>
            <div class="form-group" style="overflow: hidden;">
                <label class="col-sm-2 control-label">应用名称</label>

                <div class="col-sm-8">
                    <p class="form-control-static" ng-hide="planEdit">{{formData.appName}}</p>

                    <div ng-show="planEdit" class="form-inline">
                        <input type="text" name="appName" class="form-control mw-300" ng-model="formData.appName" ng-blur="checkAppName()" ng-readonly="formData.appId" maxlength="30" required>
                        <span ng-if="checkData.appName == 'r'"><i class="fa fa-check right" aria-hidden="true"></i></span>
                        
                        <span ng-if="checkData.appName == 'e'" class="cl"><i class="fa fa-times error" aria-hidden="true"></i>{{hintData.appName}}</span>
                    </div>
                </div>
            </div>
            <div class="form-group" style="overflow: hidden;">
                <label class="col-sm-2 control-label">应用包名或域名</label>

                <div class="col-sm-8">
                    <p class="form-control-static" ng-hide="planEdit">{{formData.appPackageName}}</p>

                    <div ng-show="planEdit" class="form-inline">
                        <input type="text" name="appPackageName" class="form-control mw-300" ng-model="formData.appPackageName" ng-blur="checkPackageName()" maxlength="50" ng-readonly="formData.appId" required>
                        <span ng-if="checkData.appPackageName == 'r'"><i class="fa fa-check right" aria-hidden="true"></i></span>
                        <span ng-if="checkData.appPackageName == 'e'" class="cl"><i class="fa fa-times error" aria-hidden="true"></i>{{hintData.appPackageName}}</span>
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-2 control-label">媒体属性</label>

                <div class="col-sm-8">
                    <p class="form-control-static" ng-hide="planEdit">{{initData.codeTable[formData.appType]}}</small></p>

                    <div ng-show="planEdit">
                        <label class="radio-inline">
                            <input type="radio" name="appType" value="38" ng-model="formData.appType" class="magic-radio" id="38">
                            <label for="38"></label>FM
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="appType" value="39" ng-model="formData.appType"  class="magic-radio" id="39">
                            <label for="39"></label>儿童
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="appType" value="40" ng-model="formData.appType"  class="magic-radio" id="40">
                            <label for="40"></label>听书
                        </label>
                        <label class="radio-inline">
                            <input type="radio" name="appType" value="41" ng-model="formData.appType"  class="magic-radio" id="41">
                            <label for="41"></label>音乐
                        </label>
                    </div>
                </div>
            </div>
        </section>

        <section class="fg-section">
            <h5>应用投放策略</h5>
            <section>
                <h5 style="margin-left: 20px;">设备定向</h5>
                <div class="form-group">
                    <label class="col-sm-2 control-label">可接受广告频次</label>

                    <div class="col-sm-8">
                        <p class="form-control-static" ng-hide="planEdit">{{formData.frequency}}<small> （按天结算不限预算具实结算）</small></p>

                        <div ng-show="planEdit">
                            <select class="form-control mw-100" name="frequency"  ng-model="formData.frequency" style="display:inline-block;">
                                <option>1</option>
                                <option>2</option>
                                <option>3</option>
                                <option>4</option>
                                <option>5</option>
                                <option>6</option>
                                <option>7</option>
                                <option>8</option>
                                <option>9</option>
                                <option>10</option>
                                <option>11</option>
                                <option>12</option>
                                <option>13</option>
                                <option>14</option>
                                <option>15</option>
                                <option>16</option>
                                <option>17</option>
                                <option>18</option>
                                <option>19</option>
                                <option>20</option>
                            </select><small> （用户每天最多可接受的广告次数）</small>
                        </div>
                    </div>
                </div>
                <div class="form-group" ng-repeat="groupItem in [
                ['targetTrade','可接收广告行业类型'],
                ['targetAdType','可接收广告形式']
            	]">
                    <label class="col-sm-2 control-label">{{groupItem[1]}}</label>
                    <div class="col-sm-8">
                        <div ng-hide="planEdit">
                            <p class="form-control-static" ng-if="formData[groupItem[0]].length == 0 ">全部（{{initData.initCode[groupItem[0]].length+ "/" + initData.initCode[groupItem[0]].length}}）</p>
                            <p class="form-control-static" ng-if="formData[groupItem[0]].length != 0">自定义（{{( formData[groupItem[0]].length) + "/" + initData.initCode[groupItem[0]].length}}）</p>
                            <div class="clearfix mt-10">
                                <p class="form-control-static pull-left iw-110" ng-if="formData[groupItem[0]].length != 0" ng-repeat="item in formData[groupItem[0]]">
                                    {{initData.codeTable[item]}}
                                </p>
                                <p class="form-control-static pull-left iw-110" ng-if="formData[groupItem[0]].length == 0" ng-repeat="item in initData.initCode[groupItem[0]]">
                                    {{initData.codeTable[item]}}
                                </p>
                            </div>
                        </div>

                        <div ng-show="planEdit">
                            <div>
                                <label class="radio-inline">
                                    <input type="radio" name="{{groupItem[0]}}" value="1" ng-model="ctrlData[groupItem[0]]" ng-click="formData[groupItem[0]] = []" class="magic-radio" id="{{groupItem[0]+$index}}">
                                    <label for="{{groupItem[0]+$index}}"></label>全部
                                </label>
                                <label class="radio-inline">
                                    <input type="radio" name="{{groupItem[0]}}" value="2" ng-model="ctrlData[groupItem[0]]"  class="magic-radio" id="{{groupItem[0]+($index+1)}}">
                                    <label for="{{groupItem[0]+($index+1)}}"></label> 自定义
                                </label>
                            </div>
                            <div class="checkbox-wapper div-checkboxList" ng-show="ctrlData[groupItem[0]] == '2'">
                                <input type="checkbox" name="allName" ng-checked="checboxAll([groupItem[0]])" value="[groupItem[0]]"  ng-click="selectAll($event, [groupItem[0]])" id="{{'selectAll'+$index}}" class="magic-checkbox">
                                <label class="selectAll-set" ng-class="{'half':halfData[groupItem[0]]}" for="{{'selectAll'+$index}}"></label>全选<br/>

                                <label class="checkbox-inline iw-110" ng-repeat="item in initData.initCode[groupItem[0]]">
                                    <input type="checkbox" name="{{[groupItem[0]]}}"  ng-true-value="102"  ng-checked="isSelected([groupItem[0]], item)" ng-click="updateSelection($event, [groupItem[0]],item)" value="{{item}}" class="magic-checkbox" id="{{initData.initCode[groupItem[0]][$index]}}">
                                    <label for="{{initData.initCode[groupItem[0]][$index]}}"></label>
                                    {{initData.codeTable[item]}}
                                </label>
                            </div>
                        </div>
                    </div>
                </div>
            </section>

            <section>
                <h5 style="margin-left: 20px;">收益分成和合约</h5>
                <div class="form-group">
                    <label class="col-sm-2 control-label">分成方式</label>

                    <div class="col-sm-8">
                        <p class="form-control-static" ng-hide="planEdit">{{initData.codeTable[formData.balanceType]}}<span ng-hide="formData.balanceType == 25">(共<span class="txt-color-r">{{formData.balanceType == "26" ? formData.price : formData.balanceType == "27" ? formData.cpcNum : ""}}</span>元)</span></p>

                        <div ng-show="planEdit">
                            <label class="radio-inline">
                                <input type="radio" name="radioPrice" value="25" ng-model="formData.balanceType" class="magic-radio" id="25">

                                <label for="25"></label>按广告收益比例分成
                            </label>
                            <label class="radio-inline">
                                <input type="radio" name="radioPrice" value="26" ng-model="formData.balanceType" class="magic-radio" id="26">

                                <label for="26"></label>按广告固定单价CPM分成
                            </label>
                            <div class="label-input" ng-show="formData.balanceType == '26'">
                                <input type="text" class="form-control" name="price" ng-pattern="/^[1-9]\d{0,8}\.?(\d{0,2})$/" ng-model="formData.price" ng-required="formData.balanceType == '26'">
                                <small> 元/CPM</small>
                            </div>
                            <label class="radio-inline ml-10">
                                <input type="radio" name="radioPrice" value="27" ng-model="formData.balanceType" class="magic-radio" id="27">
                                <label for="27"></label>按广告固定单价CPC分成
                            </label>
                            <div class="label-input"  ng-show="formData.balanceType == '27'">
                                <input type="text" class="form-control" name="cpcNum" ng-pattern="/^[1-9]\d{0,8}\.?(\d{0,2})$/" ng-model="formData.cpcNum" ng-required="formData.balanceType == '27'">
                                <small> 元/CPC</small>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label">渠道合约</label>
                    <div class="col-sm-8">
                        <div ng-show="!planEdit&&formData.contractId!=0">
                            <p class="form-control-static" >{{formData.contractId}}</p>
                        </div>
                        <div ng-hide="planEdit">
                            <p class="form-control-static " ng-if="formData.contractId == 0" >未关联</p>
                        </div>
                        <div ng-show="planEdit">
                            <p class="form-control-static pull-left" ng-if="formData.contractId>0">{{formData.contractId}}</p>
                            <a class="btn btn-link" ng-click="modelOpenChannelContract(modelChannelContractIdParam)">关联</a>
                        </div>
                    </div>
                </div>
            </section>
        </section>
        <div class="text-center">
            <button type="button" class="btn btn-primary" ng-show="planEdit" ng-click="submit()">确定</button>
            <button type="button" class="btn btn-primary" ng-hide="planEdit" ng-click="edit()">修改</button>
            <a type="button" class="btn ims-btn" ng-click="cancle()">取消</a>
        </div>
    </form>

    <script type="text/ng-template" id="myModalContent.html">
        <div class="modal-header ng-cloak">
            <h5 class="modal-title">{{param.title}}</h5>
            <span class="glyphicon glyphicon-remove" aria-hidden="true" ng-click="modelCancel()"></span>
        </div>
        <div class="modal-body ng-cloak">
            <div class="input-group input-group-sm">
                <input type="text" class="form-control" placeholder="搜索" ng-keyup="search($event)" ng-model="keyword">
				<span class="input-group-btn">
					<button class="btn btn-default" type="button" ng-click="search()" >
						<i class="glyphicon glyphicon-search"></i>
					</button>
				</span>
            </div>
            <div class="row">
                <ul class="list-unstyled advertiserList">
                    <li ng-repeat="item in param.item" ng-click="modelOk($event)" data-id="{{item.channelId}}">
                        {{ item.shortName }}
                    </li>
                </ul>
            </div>
            <s-pagination conf="paginationConf"></s-pagination>
        </div>
    </script>
    <script type="text/ng-template" id="myContract.html">
        <div class="modal-header ng-cloak">
            <h5 class="modal-title">{{param.title}}</h5>
            <span class="glyphicon glyphicon-remove" aria-hidden="true" ng-click="modelCancel()"></span>
        </div>
        <div class="modal-body ng-cloak">
            <div class="input-group input-group-sm">
                <input type="text" class="form-control" placeholder="搜索" ng-keyup="search($event)" ng-model="keyword">
				<span class="input-group-btn">
					<button class="btn btn-default" type="button" ng-click="search()">
						<i class="glyphicon glyphicon-search"></i>
					</button>
				</span>
            </div>
            <div class="row">
                <ul class="list-unstyled advertiserList">
                    <li ng-repeat="item in param.item" ng-click="modelOk($event)" data-id="{{item.id}}">
                        {{ item.id }}
                    </li>
                </ul>
            </div>
            <s-pagination conf="paginationConf"></s-pagination>
        </div>
    </script>
</div>
